Skip to content

Fix/ptp test change test cases - #1773

Open
sb-lxn wants to merge 2 commits into
developfrom
fix/ptpTestChangeTestCases
Open

Fix/ptp test change test cases#1773
sb-lxn wants to merge 2 commits into
developfrom
fix/ptpTestChangeTestCases

Conversation

@sb-lxn

@sb-lxn sb-lxn commented Apr 28, 2026

Copy link
Copy Markdown
Collaborator

Remove 13 FPS due to consistent failing.
Add 15 FPS

Fix a logic error in PTP tests when using multiple sensors per device.

Summary by CodeRabbit

  • Tests
    • Improved multi-device synchronization testing with enhanced PTP master device selection
    • Updated test parameters to better validate timing thresholds in synchronization scenarios

sb-lxn added 2 commits April 28, 2026 11:06
Signed-off-by: stas.bucik <stas.bucik@luxonis.com>
…with PTP

Signed-off-by: stas.bucik <stas.bucik@luxonis.com>
@coderabbitai

coderabbitai Bot commented Apr 28, 2026

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

Function signatures for PTP test utilities are updated to thread a ptpMasterDeviceName parameter through the setup call chain. The PTP master device selection logic is refactored to record and use the first encountered camera's device name consistently. A test's target FPS parameter is changed from 13.0f to 15.0f.

Changes

Cohort / File(s) Summary
Test Utility Header
tests/include/fsync_ptp_test_utils.hpp
Function signatures updated to accept std::string& ptpMasterDeviceName parameter in setUpCameraSocket and setupDevice declarations.
Test Utility Implementation
tests/src/onhost_tests/utility/fsync_ptp_test_utils.cpp
PTP master device selection logic refactored to thread ptpMasterDeviceName through call chain (testFsyncsetupDevicesetUpCameraSocket), recording first camera's device name for consistent master selection.
Multi-Device PTP Test
tests/src/onhost_tests/multi_device_ptp_test.cpp
Target FPS value updated from 13.0f to 15.0f, affecting sync threshold calculations.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • Feat/ptp example #1617: Both PRs modify multi-device frame-sync test utilities by updating setUpCameraSocket/setupDevice signatures to thread PTP master device name and refactoring PTP master-selection logic.

Suggested reviewers

  • jakgra

Poem

🐰 A master device name threads through the test,
Each camera knows which one is best,
Thirteen became fifteen, the sync is tight,
PTP harmony shines so bright!
Synchronization hops along just right! 🥕

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title partially describes the changes but lacks specificity and clarity about the main issue being fixed. Consider a more descriptive title like 'Fix PTP test master device selection for multi-sensor devices' or 'Update PTP tests to use 15 FPS and fix device name tracking' that clearly conveys the primary changes.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/ptpTestChangeTestCases

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@tests/src/onhost_tests/utility/fsync_ptp_test_utils.cpp`:
- Around line 211-214: ptpMasterDeviceName and the keys for slaveQueues are
currently using the non-unique string from deviceInfo.getXLinkDeviceDesc().name
(the local variable name); change the identifier source to the device MXID by
replacing uses of name with deviceInfo.getDeviceId() (or a new variable like
deviceId = deviceInfo.getDeviceId()) so ptpMasterDeviceName, the comparison
(ptpMasterDeviceName == deviceId), masterNode.emplace(...) and the slaveQueues
map use the guaranteed-unique MXID consistently throughout this function
(including the location where name is originally set around the earlier code).
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: a4ad85f6-76b1-4237-8684-2c605556abda

📥 Commits

Reviewing files that changed from the base of the PR and between cd4aa11 and 31d6ff5.

📒 Files selected for processing (3)
  • tests/include/fsync_ptp_test_utils.hpp
  • tests/src/onhost_tests/multi_device_ptp_test.cpp
  • tests/src/onhost_tests/utility/fsync_ptp_test_utils.cpp
📜 Review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
  • GitHub Check: run_vanilla_mac_tests / mac_rvc4_test (1.27.1)
  • GitHub Check: run_vanilla_mac_tests / mac_rvc4_test_usb (1.27.1)
  • GitHub Check: run_windows_tests / build_windows_tests
  • GitHub Check: run_tsan_tests / build_docker_container
🔇 Additional comments (3)
tests/src/onhost_tests/multi_device_ptp_test.cpp (1)

9-9: FPS test vector update aligns with the PR objective.

Line 9 correctly replaces the unstable 13 FPS case with 15 FPS for this test matrix.

tests/src/onhost_tests/utility/fsync_ptp_test_utils.cpp (1)

186-187: Parameter threading for ptpMasterDeviceName is wired correctly through the call chain.

The new argument is consistently propagated from testFsync to setupDevice to setUpCameraSocket, which fixes the multi-sensor state-sharing gap in this flow.

Also applies to: 262-263, 282-282, 338-341

tests/include/fsync_ptp_test_utils.hpp (1)

59-60: Header declarations are consistent with the implementation changes.

The added std::string& ptpMasterDeviceName parameter is correctly reflected in both public declarations.

Also applies to: 72-73

Comment on lines +211 to 214
ptpMasterDeviceName = name;
}
if (ptpMasterDeviceName == name) {
masterNode.value().emplace(dai::toString(socket), outNode);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🌐 Web query:

In DepthAI, is dai::DeviceInfo::getXLinkDeviceDesc().nameguaranteed to be unique across simultaneously connected devices? If not, which identifier is guaranteed unique for device identity in tests (for examplegetDeviceId() or MXID)?

💡 Result:

No, dai::DeviceInfo::getXLinkDeviceDesc.name is not guaranteed to be unique across simultaneously connected devices. The name field in DeviceInfo (populated from XLink's deviceDesc_t.name via the DeviceInfo constructor) represents connection-specific identifiers like USB port paths (e.g., '1.3') or IP addresses (e.g., '192.168.33.201'), which are not unique—multiple devices can share USB hubs/ports or IPs in different scenarios. Official examples show different devices with unique names but emphasize MxId uniqueness. Device::getDeviceName is also unpredictable per GitHub issues. The identifier guaranteed unique for device identity is the MXID (Myriad X ID), accessed via DeviceInfo::getMxId or info.mxid. Official docs explicitly call it the "Unique Mx (chip) identification code", used to distinguish devices in multi-device setups (e.g., XLinkConnection::getDeviceByMxId(mxId)). Examples list distinct MXIDs like '18443010D116631200' for different devices. getDeviceId appears as an alias for MXID in some docs.

Citations:


🏁 Script executed:

# Get the context around lines 211-214
sed -n '200,225p' tests/src/onhost_tests/utility/fsync_ptp_test_utils.cpp

Repository: luxonis/depthai-core

Length of output: 1160


🏁 Script executed:

# Check where ptpMasterDeviceName is defined and how it's used
rg 'ptpMasterDeviceName' tests/src/onhost_tests/utility/fsync_ptp_test_utils.cpp -B 2 -A 2

Repository: luxonis/depthai-core

Length of output: 1415


🏁 Script executed:

# Check what methods are available on DeviceInfo object in the file
rg 'deviceInfo\.' tests/src/onhost_tests/utility/fsync_ptp_test_utils.cpp | head -30

Repository: luxonis/depthai-core

Length of output: 204


🏁 Script executed:

# Look for getDeviceId or getMxId usage in the codebase
rg 'getMxId\(\)|getDeviceId\(\)' tests/src/onhost_tests/utility/fsync_ptp_test_utils.cpp

Repository: luxonis/depthai-core

Length of output: 370


🏁 Script executed:

# Check how slaveQueues map is organized and used with the name identifier
sed -n '185,295p' tests/src/onhost_tests/utility/fsync_ptp_test_utils.cpp | rg -A 2 -B 2 'slaveQueues'

Repository: luxonis/depthai-core

Length of output: 1590


🏁 Script executed:

# Check the overall data flow - how masterNode and slaveQueues store devices
grep -n 'masterNode\|slaveQueues' tests/src/onhost_tests/utility/fsync_ptp_test_utils.cpp | head -20

Repository: luxonis/depthai-core

Length of output: 1676


Change PTP master selection to use a guaranteed-unique device identifier.

At lines 211–214, the PTP master device is selected and compared using name, which is derived from deviceInfo.getXLinkDeviceDesc().name. This value is not guaranteed to be unique across simultaneously connected devices. The verified unique identifier for device identity in DepthAI is the MXID, accessible via deviceInfo.getDeviceId(). Multiple devices sharing the same name could be misclassified as the master, breaking PTP synchronization.

Additionally, the slaveQueues map is also keyed by the same non-unique name identifier. For a complete fix, consider updating the source where name is derived (around line 271) to use getDeviceId() instead, which would consistently fix both ptpMasterDeviceName and the slave queue organization throughout this function.

Suggested approach

Change the source identifier to the unique device ID:

-    std::string name = deviceInfo.getXLinkDeviceDesc().name;
+    std::string name = deviceInfo.getDeviceId();

This single change will ensure both PTP master selection and device queue organization use the guaranteed-unique identifier.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/src/onhost_tests/utility/fsync_ptp_test_utils.cpp` around lines 211 -
214, ptpMasterDeviceName and the keys for slaveQueues are currently using the
non-unique string from deviceInfo.getXLinkDeviceDesc().name (the local variable
name); change the identifier source to the device MXID by replacing uses of name
with deviceInfo.getDeviceId() (or a new variable like deviceId =
deviceInfo.getDeviceId()) so ptpMasterDeviceName, the comparison
(ptpMasterDeviceName == deviceId), masterNode.emplace(...) and the slaveQueues
map use the guaranteed-unique MXID consistently throughout this function
(including the location where name is originally set around the earlier code).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants